Function Reference

_ArraySearch

Finds an entry within an one-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted.)

#include <Array.au3>
_ArraySearch($avArray, $vWhat2Find, $iStart = 0, $iEnd = 0, $iCaseSense = 0)

 

Parameters

$avArray The array to search
$vWhat2Find What to search $avArray for
$iStart (Optional) Start array index for search, normally set to 0 or 1. If omitted it is set to 0
$iEnd (Optional) End array index for search. If omitted or set to 0 it is set to Ubound($AvArray)-
$iCaseSense (Optional) If set to 1 then search is case sensitive

 

Return Value

Success:The first found instance of $vWhat2Find in $avArray
Failure:Returns -1 and sets @Error on Errors.
   @Error=1 $avArray is not an array
   @Error=2 $iStart is greater than UBound($AvArray)-1
   @Error=3 $iEnd is greater than UBound($AvArray)-1
   @Error=4 $iStart is greater than $iEnd
   @Error=5 $iCaseSense was invalid. (Must be 0 or 1)
   @Error=6 $vWhat2Find was not found in $avArray

 

Remarks

 This function might be slower than _ArrayBinarySearch() but is useful when the array's order can't be altered.

 

Related

_ArrayBinarySearch

 

Example


#Include<Array.au3>
Dim $Array[6]
$Array[0] = "String0"
$Array[1] = "String1"
$Array[2] = "String2"
$Array[3] = "String3"
$Array[4] = "String4"
$Array[5] = "String5"

$Input = InputBox("ArraySearch Demo", "String To Find?")
If @error Then Exit

$Pos = _ArraySearch ($Array, $Input)
Select
    Case $Pos = -1
        MsgBox(0, "Not Found", '"' & $Input & '" was not found in the array.')
    Case Else
        MsgBox(0, "Found", '"' & $Input & '" was found in the array at pos ' & $Pos & ".")
EndSelect